﻿using System;
using Microsoft.Practices.Prism;
using Microsoft.Practices.Prism.MetroIocExtensions;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using SampleModule;
using SimplePrismSample.Views;
using Windows.UI.Xaml;

namespace Diskordia.Braindump.Desktop
{
	/// <summary>
	/// Boostrapper for the braindump metro app.
	/// </summary>
	public class SimpleBootstrapper : MetroIocBootstrapper
	{
		#region MetroIocBootstrapper members

		/// <summary>
		/// Creates the <see cref="IModuleCatalog"/> used by Prism.
		/// </summary>
		///  <remarks>
		/// The base implementation returns a new ModuleCatalog.
		/// </remarks>
		protected override IModuleCatalog CreateModuleCatalog()
		{
			return new AggregateModuleCatalog();
		}

		/// <summary>
		/// Configures the <see cref="IModuleCatalog"/> used by Prism.
		/// </summary>
		protected override void ConfigureModuleCatalog()
		{
			Type libraryExplorerModule = typeof(MySampleModule);
			this.ModuleCatalog.AddModule(new ModuleInfo(libraryExplorerModule.Name, libraryExplorerModule.AssemblyQualifiedName));
		}

		/// <summary>
		/// Creates the shell or main window of the application.
		/// </summary>
		/// <returns>The shell of the application.</returns>
		/// <remarks>
		/// If the returned instance is a <see cref="DependencyObject"/>, the
		/// <see cref="Bootstrapper"/> will attach the default <seealso cref="IRegionManager"/> of
		/// the application in its <see cref="RegionManager.RegionManagerProperty"/> attached property
		/// in order to be able to add regions by using the <seealso cref="RegionManager.RegionNameProperty"/>
		/// attached property from XAML.
		/// </remarks>
		protected override DependencyObject CreateShell()
		{
			return new Shell();
		}

		/// <summary>
		/// Initializes the shell.
		/// </summary>
		protected override void InitializeShell()
		{
			// Place the frame in the current Window and ensure that it is active
			Window.Current.Content = (UIElement)this.Shell;
			Window.Current.Activate();
		}

		#endregion
	}
}